package com.huoyun.user.service;

import com.huoyun.base.bean.Page;
import com.huoyun.user.bean.Complaint;
import com.huoyun.user.dao.ComplaintDao;

public class ComplaintServiceImpl implements ComplaintService{
	
	public ComplaintDao complaintDao;
	public ComplaintDao getComplaintDao() {
		return complaintDao;
	}


	public void setComplaintDao(ComplaintDao complaintDao) {
		this.complaintDao = complaintDao;
	}


	public int insertComplaint(Complaint complaint) {
		// TODO Auto-generated method stub
		return complaintDao.insertComplaint(complaint);
	}


	public int updateComplaint(Complaint complaint) {
		// TODO Auto-generated method stub
		return complaintDao.updateComplaint(complaint);
	}


	public int deleteComplaint(long complaintId) {
		// TODO Auto-generated method stub
		return complaintDao.deleteComplaint(complaintId);
	}


	public Complaint getComplaintById(long id) {
		// TODO Auto-generated method stub
		return complaintDao.getComplaintById(id);
	}

	public Page getComplaintsByUserId(
		com.huoyun.user.service.evt.GetComplaintsByUserIdEvt getComplaintsByUserIdEvt) {
		// TODO Auto-generated method stub
		//构造dao需要的参数
		com.huoyun.user.dao.evt.GetComplaintsByUserIdEvt evt = new com.huoyun.user.dao.evt.GetComplaintsByUserIdEvt();
		evt.setUserId(getComplaintsByUserIdEvt.getUserId());
		evt.setPageNo(getComplaintsByUserIdEvt.getPageNo());
		evt.setPageCount(getComplaintsByUserIdEvt.getPageCount());
		
		//获取订单的总记录数
		long totalRecord = complaintDao.getComplaintCountByUserid(getComplaintsByUserIdEvt.getUserId());
		
		Page page = new Page();
		page.setPageNo(getComplaintsByUserIdEvt.getPageNo());
		page.setPageCount(getComplaintsByUserIdEvt.getPageCount());
		
		//设置总记录数
		page.setTotalRecord(totalRecord);
		
		//设置显示的记录列表
		page.setObjectList(complaintDao.queryList(evt));
		
		return page;
	}

}